package com.echo.register.mapper;

import com.echo.register.domain.VoteRecords;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface RecordsMapper {

    @Select("select * from vote_records where um_ip = #{ip}")
    VoteRecords getRecordsByIp(String ip);

    @Select("select * from vote_records where um_id = #{umId}")
    VoteRecords getRecordsByUmId(String umId);

    @Insert("INSERT INTO vote_records(um_id, um_ip, vote_count, created_time, updated_time, records_kjcx, records_aqws, records_zyyy, records_sjxf, records_fwmy, records_kjxr)" +
            "VALUES (#{umId}, #{umIp}, #{voteCount}, #{createdTime}, #{updatedTime}, #{recordsKjcx}, #{recordsAqws}, #{recordsZyyy}, #{recordsSjxf}, #{recordsFwmy}, #{recordsKjxr});")
    void insertRecords(VoteRecords voteRecords);

    @Update("update vote_records set vote_count = #{voteCount}, updated_time = #{updatedTime}, records_kjcx = #{recordsKjcx} , records_aqws = #{recordsAqws}, records_zyyy = #{recordsZyyy}, " +
            "records_sjxf = #{recordsSjxf}, records_fwmy = #{recordsFwmy}, records_kjxr = #{recordsKjxr} where um_id = #{umId}")
    void updateRecords(VoteRecords records);
}
